/////precompiled////////
#include "precompiled.h"
////////////////////////


#include "frm_filler_TNodeSolidLine.h"
#include "frm_control_TRow.h"
using namespace frm;
using namespace filler;

//
void TNodeSolidLine::TBase_Paint(TComponent &Component,TPaint &Paint)
{
  control::TRowChildrenIndent *Indent = dynamic_cast
    <control::TRowChildrenIndent*>(&Component);
  if (!Indent) { Except("TBase_Paint[!Indent]");}

  control::TRow &Row = Indent->Row;
  int LineCenter = Paint.GRect.RThis.Left + Paint.GRect.RThis.Width/2;
  int LineBottom = 0;

  Paint.DC.Select(Pen);
  bool BeforeVisible = false;

  for (int N = 0; N < Row.Children->GetChildrenCount(); N++)
  {
    control::TRow *Child = dynamic_cast<control::TRow*>(&Row.Children->GetChild(N));

    if (Child)
    {
      TGeometryRect ChildGRect,ChildrenPanelGRect;

        ChildrenPanelGRect.RParent        = Paint.GRect.RParent;
        ChildrenPanelGRect.RParentVisible = Paint.GRect.RParent;
        ChildrenPanelGRect.RThisVisible   = Paint.GRect.RParent;//.Size();
        ChildrenPanelGRect.RThis          = Paint.GRect.RParent;//.Size();

//ChildrenPanelGRect = Paint.GRect;

      if
      (
        Row.ChildrenPanel->CalcGeometryRect
        (
          Child->Caption,
          //Paint.RClientPaint, //ChildrenPanelGRect.RParent,
          ChildrenPanelGRect,
          ChildGRect
        )
      )
      {
        BeforeVisible = true;
        int Top = ChildGRect.RThis.Top + ChildGRect.RThis.Height/2;

        Paint.DC.MoveTo(LineCenter               ,Top);
        Paint.DC.LineTo(Paint.GRect.RThis.Right(),Top);
        LineBottom = Top;
      }
      else if (BeforeVisible)
      {
        LineBottom = Paint.RClientPaint.Bottom();
        break;
      }
    }
  }

  if (LineBottom)
  {
    Paint.DC.MoveTo(LineCenter,Paint.GRect.RThis.Top);
    Paint.DC.LineTo(LineCenter,LineBottom);
  }
}
